796975697ae8d3b7c064914a5cafcfa0014ba660
[lhc/web/wiklou.git] / tests / phpunit / includes / media / SVGTest.php
1 <?php
2 class SVGTest extends MediaWikiTestCase {
3
4 protected function setUp() {
5 parent::setUp();
6
7 $this->filePath = __DIR__ . '/../../data/media/';
8
9 $this->setMwGlobals( 'wgShowEXIF', true );
10
11 $this->backend = new FSFileBackend( array(
12 'name' => 'localtesting',
13 'lockManager' => 'nullLockManager',
14 'containerPaths' => array( 'data' => $this->filePath )
15 ) );
16 $this->repo = new FSRepo( array(
17 'name' => 'temp',
18 'url' => 'http://localhost/thumbtest',
19 'backend' => $this->backend
20 ) );
21
22 $this->handler = new SVGHandler;
23 }
24
25 /**
26 * @param $filename String
27 * @param $expected Array The expected independent metadata
28 * @dataProvider providerGetIndependentMetaArray
29 */
30 public function testGetIndependentMetaArray( $filename, $expected ) {
31 $file = $this->dataFile( $filename, 'image/svg+xml' );
32 $res = $this->handler->getCommonMetaArray( $file );
33
34 $this->assertEquals( $res, $expected );
35 }
36
37 public function providerGetIndependentMetaArray() {
38 return array(
39 array( 'Tux.svg', array(
40 'ObjectName' => 'Tux',
41 'ImageDescription' => 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
42 ) ),
43 array( 'Wikimedia-logo.svg', array() )
44 );
45 }
46
47 private function dataFile( $name, $type ) {
48 return new UnregisteredLocalFile( false, $this->repo,
49 "mwstore://localtesting/data/$name", $type );
50 }
51 }